﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using YArchitech.Controls;
using YArchitech.LIB;
using libxl;

namespace YArchitech.HVAC
{
	public class ExportExcel
	{
		public ExportExcel()
		{
			Log.Info(new string[]
			{
				"creat book...."
			});
			this.book = new BinBook();
			this.book.setKey("Beijing YArchitech Tongxing Technology Co.,Ltd", "windows-282b2c0f08cbe70966b4616ea0i8d7n0");
			this.CreateExcelCellFormat();
		}

		public ExportExcel(BuildingSystem build, HYHeatingSystemOption option) : this()
		{
			this.buildingSystem = build;
			this.heatingOption = option;
		}

		public bool WriteExcel(BackgroundWorker bWorker = null)
		{
			bool result;
			try
			{
				this.backWorker = bWorker;
				this.WriteFirstPage();
				this.WriteSecondPage();
				this.SaveFile();
				Process.Start(this.path);
				GC.Collect();
				GC.WaitForPendingFinalizers();
				GC.Collect();
				result = true;
			}
			catch (System.Exception ex)
			{
				YJKMessageBox.Information(ex.Message);
				result = false;
			}
			return result;
		}

		private void WriteFirstPage()
		{
			int num = 0;
			Sheet sheet = this.book.addSheet("水力计算表");
			this.SetBkWorInfo(0, "开始写计算书……");
			this.WriteTitle(sheet, num++, 0, 11, this.title1);
			this.WriteBaseInfos(sheet, ref num);
			num += 2;
			this.SetBkWorInfo(2, "开始写干管道数据……");
			this.WriteMainPipeInfos(sheet, ref num);
			num++;
			this.SetBkWorInfo(3, "开始写立管信息……");
			this.WriteRiserPipeInfos(sheet, ref num);
			this.SetBkWorInfo(5, "开始写给分户系统内部信息……");
			this.WriteIndoorSystemData(sheet, ref num);
			num++;
			this.SetBkWorInfo(30, "写入散热器数据信息……");
			this.WriteEquipmentInfos(sheet, ref num);
			num++;
			this.WriteSubTitle(sheet, num++, 0, 8, "系统最不利环路信息");
			this.WriteComebinCell(sheet, num++, num++, 0, 8, this.buildingSystem.WorstCircleInfo, this.leftFormat);
			num += 2;
			this.WriteCalcTime(sheet, ref num);
		}

		private void WriteBaseInfos(Sheet sheet, ref int rowIndex)
		{
			rowIndex++;
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, 4, "设计软件：", this.rightFormat);
			int rowStart = rowIndex;
			int num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart, num, 5, 8, "盈建科机电 for Revit 2014-2017", this.leftFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, 4, "计算时间：", this.rightFormat);
			int rowStart2 = rowIndex;
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart2, num, 5, 8, DateTime.Now.ToString(), this.leftFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, 4, "室内供回干管形式：", this.rightFormat);
			int rowStart3 = rowIndex;
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart3, num, 5, 8, (this.buildingSystem.ConnectType == 0) ? "同程" : "异程", this.leftFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, 4, "室内供回立管形式：", this.rightFormat);
			int rowStart4 = rowIndex;
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart4, num, 5, 8, (this.buildingSystem.RisePipes[0].ConnectType == 0) ? "同程" : "异程", this.leftFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, 4, "采暖形式：", this.rightFormat);
			int rowStart5 = rowIndex;
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart5, num, 5, 8, "散热器采暖", this.leftFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, 4, "供水温度：", this.rightFormat);
			int rowStart6 = rowIndex;
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart6, num, 5, 8, this.heatingOption.SupplyTemperature + "℃", this.leftFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, 4, "回水温度：", this.rightFormat);
			int rowStart7 = rowIndex;
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart7, num, 5, 8, this.heatingOption.ReturnTemperature + "℃", this.leftFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, 4, "系统总流量：", this.rightFormat);
			int rowStart8 = rowIndex;
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart8, num, 5, 8, this.buildingSystem.SupplyPipes.At(1).Flow.ToString("F2") + "m3/h", this.leftFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, 4, "系统总压降：", this.rightFormat);
			int rowStart9 = rowIndex;
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart9, num, 5, 8, this.buildingSystem.Resistance.ToString("F2") + "Pa", this.leftFormat);
		}

		private void WriteMainPipeInfos(Sheet sheet, ref int rowIndex)
		{
			rowIndex++;
			int num = rowIndex;
			rowIndex = num + 1;
			int colEnd = this.WriteHeartOfPipe(sheet, num);
			this.WriteSubTitle(sheet, rowIndex - 2, 0, colEnd, "总供回水干管水力计算表");
			this.WritePipeSetData(this.buildingSystem.SupplyPipes, sheet, ref rowIndex, "");
			this.WritePipeSetData(this.buildingSystem.BackPipes, sheet, ref rowIndex, "");
		}

		private void WriteRiserPipeInfos(Sheet sheet, ref int rowIndex)
		{
			for (int i = 1; i <= this.buildingSystem.RisePipes.Count; i++)
			{
				RisePipeSystem at = this.buildingSystem.GetAt(i);
				rowIndex++;
				int num = rowIndex;
				rowIndex = num + 1;
				int colEnd = this.WriteHeartOfPipe(sheet, num);
				this.WriteSubTitle(sheet, rowIndex - 2, 0, colEnd, "共用立管[" + i + "]水力计算表");
				this.WritePipeSetData(at.SupplyPipes, sheet, ref rowIndex, "");
				this.WritePipeSetData(at.BackPipes, sheet, ref rowIndex, "");
				rowIndex++;
			}
		}

		private void WriteIndoorSystemData(Sheet sheet, ref int rowIndex)
		{
			for (int i = 1; i <= this.buildingSystem.RisePipes.Count; i++)
			{
				RisePipeSystem at = this.buildingSystem.GetAt(i);
				for (int j = 1; j <= at.FloorSystems.Count; j++)
				{
					FloorSystem at2 = at.GetAt(j);
					for (int k = 1; k <= at2.InDoorSystem.Count; k++)
					{
						string name = string.Format("公用立管[{0}]楼层[{1}]户内系统[{2}]水力计算表", i, j, k);
						this.WriteIndoorSystemData(at2.GetAt(k), name, sheet, ref rowIndex);
					}
				}
			}
		}

		private void WriteIndoorSystemData(IndoorSystem indoor, string name, Sheet sheet, ref int rowIndex)
		{
			rowIndex++;
			int num = rowIndex;
			rowIndex = num + 1;
			int colEnd = this.WriteHeartOfPipe(sheet, num);
			this.WriteSubTitle(sheet, rowIndex - 2, 0, colEnd, name);
			if (indoor.SupplyPipe != null)
			{
				this.WritePipeData(indoor.SupplyPipe, sheet, ref rowIndex, "");
				this.WritePipeData(indoor.BackPipe, sheet, ref rowIndex, "");
			}
			for (int i = 1; i <= indoor.Loops.Count; i++)
			{
				this.WritePipeSetData(indoor.GetAt(i).SupplyPipes, sheet, ref rowIndex, string.Format("{0}环", i));
				this.WritePipeSetData(indoor.GetAt(i).BackPipes, sheet, ref rowIndex, string.Format("{0}环", i));
			}
			rowIndex++;
		}

		private void WriteEquipmentInfos(Sheet sheet, ref int rowIndex)
		{
			int num = rowIndex;
			rowIndex = num + 1;
			this.WriteSubTitle(sheet, num, 0, 8, "散热器计算表");
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteEquipmentTitle(sheet, num);
			this.WriteEachEquipment(sheet, ref rowIndex);
		}

		private void WriteEquipmentTitle(Sheet sheet, int rowIndex)
		{
			sheet.writeStr(rowIndex, 0, "位置", this.textFormat);
			sheet.writeStr(rowIndex, 1, "环路", this.textFormat);
			sheet.writeStr(rowIndex, 2, "编号", this.textFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 3, 5, "类型", this.textFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 6, 7, "温控阀压差(Pa)", this.textFormat);
			sheet.writeStr(rowIndex, 8, "不平衡率", this.textFormat);
		}

		private void WriteEachEquipment(Sheet sheet, ref int rowIndex)
		{
			for (int i = 1; i <= this.buildingSystem.RisePipes.Count; i++)
			{
				RisePipeSystem at = this.buildingSystem.GetAt(i);
				for (int j = 1; j <= at.FloorSystems.Count; j++)
				{
					FloorSystem at2 = at.GetAt(j);
					for (int k = 1; k <= at2.InDoorSystem.Count; k++)
					{
						string local = string.Format("立管[{0}]楼层[{1}]户内[{2}]", i, j, k);
						this.WriteEqLoopData(at2.GetAt(k), local, sheet, ref rowIndex);
					}
				}
			}
		}

		private void WriteEqLoopData(IndoorSystem indoor, string local, Sheet sheet, ref int rowIndex)
		{
			int rowStart = rowIndex;
			for (int i = 1; i <= indoor.Loops.Count; i++)
			{
				IndoorLoop at = indoor.GetAt(i);
				for (int j = 1; j <= at.EquipmentLoops.Count; j++)
				{
					EquipmentLoop at2 = at.GetAt(j);
					sheet.writeNum(rowIndex, 1, (double)i, this.intFormat);
					sheet.writeNum(rowIndex, 2, (double)j, this.intFormat);
					this.WriteComebinCell(sheet, rowIndex, rowIndex, 3, 5, at2.EquipmentName, this.textFormat);
					this.WriteComebinCell(sheet, rowIndex, rowIndex, 6, 7, at2.ResistTcValve, this.douFormat);
					int num = rowIndex;
					rowIndex = num + 1;
					sheet.writeNum(num, 8, at2.RateUnbalance, this.percentFormat);
				}
			}
			this.WriteComebinCell(sheet, rowStart, rowIndex - 1, 0, 0, local, this.textFormat);
		}

		private int WriteHeartOfPipe(Sheet sheet, int rowIndex)
		{
			int num = 0;
			sheet.writeStr(rowIndex, num++, "管段编号", this.textFormat);
			sheet.writeStr(rowIndex, num++, "流量(m3/h)", this.textFormat);
			sheet.writeStr(rowIndex, num++, "公称直径", this.textFormat);
			sheet.writeStr(rowIndex, num++, "长度(m)", this.textFormat);
			sheet.writeStr(rowIndex, num++, "∑ξ", this.textFormat);
			sheet.writeStr(rowIndex, num++, "V(m/s)", this.textFormat);
			sheet.writeStr(rowIndex, num++, "Rm(Pa/m)", this.textFormat);
			sheet.writeStr(rowIndex, num++, "ΔPy(Pa)", this.textFormat);
			sheet.writeStr(rowIndex, num++, "ΔPj(Pa)", this.textFormat);
			sheet.writeStr(rowIndex, num, "ΔP(Pa)", this.textFormat);
			return num;
		}

		private void WritePipeSetData(PipeSet pSet, Sheet sheet, ref int rowIndex, string addInfo = "")
		{
			for (int i = 1; i <= pSet.Count; i++)
			{
				HyCalcPipe pipe = pSet.At(i);
				this.WritePipeData(pipe, sheet, ref rowIndex, addInfo);
			}
		}

		private void WritePipeData(HyCalcPipe pipe, Sheet sheet, ref int rowIndex, string addInfo = "")
		{
			int col = 0;
			sheet.writeStr(rowIndex, col++, addInfo + pipe.Name, this.textFormat);
			sheet.writeNum(rowIndex, col++, pipe.Flow, this.douFormat);
			sheet.writeNum(rowIndex, col++, (double)pipe.DN, this.intFormat);
			sheet.writeNum(rowIndex, col++, pipe.Length, this.douFormat);
			sheet.writeNum(rowIndex, col++, pipe.ResCoefLocal, this.douFormat);
			sheet.writeNum(rowIndex, col++, pipe.Velocity, this.douFormat);
			sheet.writeNum(rowIndex, col++, pipe.Rm, this.douFormat);
			sheet.writeNum(rowIndex, col++, pipe.Resistancey, this.douFormat);
			sheet.writeNum(rowIndex, col++, pipe.Resistancej, this.douFormat);
			int num = rowIndex;
			rowIndex = num + 1;
			sheet.writeNum(num, col, pipe.Resistance, this.douFormat);
		}

		private void WriteCalcTime(Sheet sheet, ref int rowIndex)
		{
			rowIndex++;
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 1, 2, "设计软件：", this.rightFormat);
			int rowStart = rowIndex;
			int num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart, num, 3, 6, Product.GetSoftWareName() + " " + Product.GetSoftWareBuildVer(), this.leftFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 1, 2, "计算时间：", this.rightFormat);
			int rowStart2 = rowIndex;
			num = rowIndex;
			rowIndex = num + 1;
			this.WriteComebinCell(sheet, rowStart2, num, 3, 6, DateTime.Now.ToString(), this.leftFormat);
		}

		private void WriteSecondPage()
		{
			int num = 0;
			Sheet sheet = this.book.addSheet("高级设置");
			this.SetBkWorInfo(20, "开始写高级设置，干管局阻……");
			this.WriteTitle(sheet, num++, 0, 6, this.title2);
			this.WriteMainPipeValveInfo(sheet, ref num);
			this.SetBkWorInfo(5, "开始写立管局阻……");
			this.WriteRiserPipeValveInfo(sheet, ref num);
			this.SetBkWorInfo(5, "开始写各个户内系统的局阻信息……");
			this.WriteIndoorSystemPipeValveInfo(sheet, ref num);
			this.SetBkWorInfo(30, "导出计算书完成。");
		}

		private void WriteMainPipeValveInfo(Sheet sheet, ref int rowIndex)
		{
			rowIndex += 2;
			int num = rowIndex;
			rowIndex += 2;
			int num2 = this.WritePipeSetValveInfos(this.buildingSystem.SupplyPipes, sheet, ref rowIndex, "");
			int num3 = this.WritePipeSetValveInfos(this.buildingSystem.BackPipes, sheet, ref rowIndex, "");
			int num4 = (num3 > num2) ? num3 : num2;
			this.WriteSubTitle(sheet, num, 0, num4, "总供回水干管局阻信息表");
			this.WriteHeaderofResCoefLocal(sheet, num + 1, num4);
			this.WriteBlankCell(sheet, num + 2, rowIndex - 1, 2, num4);
			rowIndex += 2;
		}

		private void WriteRiserPipeValveInfo(Sheet sheet, ref int rowIndex)
		{
			for (int i = 1; i <= this.buildingSystem.RisePipes.Count; i++)
			{
				int num = rowIndex;
				rowIndex += 2;
				int num2 = 0;
				RisePipeSystem at = this.buildingSystem.GetAt(i);
				int num3 = this.WritePipeSetValveInfos(at.SupplyPipes, sheet, ref rowIndex, "");
				num2 = ((num2 < num3) ? num3 : num2);
				num3 = this.WritePipeSetValveInfos(at.BackPipes, sheet, ref rowIndex, "");
				num2 = ((num2 < num3) ? num3 : num2);
				this.WriteSubTitle(sheet, num, 0, num2, string.Format("共用立管[{0}]局阻信息表", i));
				this.WriteHeaderofResCoefLocal(sheet, num + 1, num2);
				this.WriteBlankCell(sheet, num + 2, rowIndex - 1, 2, num2);
				rowIndex++;
			}
		}

		private void WriteIndoorSystemPipeValveInfo(Sheet sheet, ref int rowIndex)
		{
			for (int i = 1; i <= this.buildingSystem.RisePipes.Count; i++)
			{
				RisePipeSystem at = this.buildingSystem.GetAt(i);
				for (int j = 1; j <= at.FloorSystems.Count; j++)
				{
					FloorSystem at2 = at.GetAt(j);
					for (int k = 1; k <= at2.InDoorSystem.Count; k++)
					{
						string titleName = string.Format("公用立管[{0}]楼层[{1}]户内系统[{2}]局阻信息表", i, j, k);
						this.WriteIndoorSystemPipeValveInfo(at2.GetAt(k), titleName, sheet, ref rowIndex);
					}
				}
			}
		}

		private void WriteIndoorSystemPipeValveInfo(IndoorSystem indoor, string titleName, Sheet sheet, ref int rowIndex)
		{
			int num = rowIndex;
			int num2 = 0;
			rowIndex += 2;
			if (indoor.SupplyPipe != null)
			{
				int num3 = this.WritePipeValveInfos(indoor.SupplyPipe, sheet, ref rowIndex, "");
				int num4 = this.WritePipeValveInfos(indoor.BackPipe, sheet, ref rowIndex, "");
				num2 = ((num3 > num4) ? num3 : num4);
			}
			for (int i = 1; i <= indoor.Loops.Count; i++)
			{
				int num5 = this.WritePipeSetValveInfos(indoor.GetAt(i).SupplyPipes, sheet, ref rowIndex, string.Format("{0}环", i));
				int num6 = this.WritePipeSetValveInfos(indoor.GetAt(i).BackPipes, sheet, ref rowIndex, string.Format("{0}环", i));
				num2 = ((num2 < ((num5 > num6) ? num5 : num6)) ? ((num5 > num6) ? num5 : num6) : num2);
			}
			this.WriteSubTitle(sheet, num, 0, num2, titleName);
			this.WriteHeaderofResCoefLocal(sheet, num + 1, num2);
			this.WriteBlankCell(sheet, num + 2, rowIndex - 1, 2, num2);
			rowIndex++;
		}

		private int WritePipeSetValveInfos(PipeSet pSet, Sheet sheet, ref int rowIndex, string addStr = "")
		{
			int num = 0;
			for (int i = 1; i <= pSet.Count; i++)
			{
				HyCalcPipe pipe = pSet.At(i);
				int num2 = this.WritePipeValveInfos(pipe, sheet, ref rowIndex, addStr);
				num = ((num < num2) ? num2 : num);
			}
			return num;
		}

		private int WritePipeValveInfos(HyCalcPipe pipe, Sheet sheet, ref int rowIndex, string addStr = "")
		{
			int num = 0;
			this.WriteComebinCell(sheet, rowIndex, rowIndex + 1, num, num++, addStr + pipe.Name, this.textFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex + 1, num, num++, pipe.ResCoefLocal, this.douFormat);
			Dictionary<string, int> dictionary = this.CountTypeNumber(pipe.Valves);
			foreach (string text in dictionary.Keys)
			{
				sheet.writeStr(rowIndex, num, text, this.textFormat);
				sheet.writeNum(rowIndex + 1, num++, (double)dictionary[text], this.intFormat);
			}
			rowIndex += 2;
			return num;
		}

		private Dictionary<string, int> CountTypeNumber(IList<ValveAndFitting> valves)
		{
			List<string> list = (from v in valves
			select v.TypeName).Distinct<string>().ToList<string>();
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			using (List<string>.Enumerator enumerator = list.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					string item = enumerator.Current;
					int value = valves.Count((ValveAndFitting v) => v.TypeName == item);
					dictionary.Add(item, value);
				}
			}
			return dictionary;
		}

		private void WriteHeaderofResCoefLocal(Sheet sheet, int rowIndex, int colNum)
		{
			sheet.writeStr(rowIndex, 0, "编号", this.textFormat);
			sheet.writeStr(rowIndex, 1, "局阻系数", this.textFormat);
			this.WriteComebinCell(sheet, rowIndex, rowIndex, 2, colNum, "阀件", this.textFormat);
		}

		private void WriteBlankCell(Sheet sheet, int rowStart, int rowEnd, int colStart, int colEnd)
		{
			for (int i = rowStart; i <= rowEnd; i++)
			{
				for (int j = colStart; j <= colEnd; j++)
				{
					if (sheet.cellType(i, j) == CellType.CELLTYPE_EMPTY)
					{
						sheet.writeBlank(i, j, this.textFormat);
					}
				}
			}
		}

		private void WriteTitle(Sheet sheet, int rowIndex, int colStart, int colEnd, string strValue)
		{
			this.WriteComebinCell(sheet, rowIndex, rowIndex, colStart, colEnd, strValue, this.titleFormat);
		}

		private void WriteSubTitle(Sheet sheet, int rowIndex, int colStart, int colEnd, string strValue)
		{
			this.WriteComebinCell(sheet, rowIndex, rowIndex, colStart, colEnd, strValue, this.subTitleFormat);
		}

		private void WriteComebinCell(Sheet sheet, int rowStart, int rowEnd, int colStart, int colEnd, string value, Format format)
		{
			sheet.writeStr(rowStart, colStart, value, format);
			sheet.setMerge(rowStart, rowEnd, colStart, colEnd);
		}

		private void WriteComebinCell(Sheet sheet, int rowStart, int rowEnd, int colStart, int colEnd, double value, Format format)
		{
			sheet.writeNum(rowStart, colStart, value, format);
			sheet.setMerge(rowStart, rowEnd, colStart, colEnd);
		}

		private void CreateExcelCellFormat()
		{
			this.textFormat = this.book.addFormat();
			this.textFormat.setBorder(BorderStyle.BORDERSTYLE_THIN);
			this.textFormat.font = this.CreateTextFont();
			this.textFormat.alignH = AlignH.ALIGNH_CENTER;
			this.textFormat.alignV = AlignV.ALIGNV_DISTRIBUTED;
			this.titleFormat = this.book.addFormat(this.textFormat);
			this.titleFormat.font = this.CreateFileTitleFont();
			this.titleFormat.setBorder(BorderStyle.BORDERSTYLE_NONE);
			this.subTitleFormat = this.book.addFormat(this.titleFormat);
			this.subTitleFormat.font = this.CreateSubTitleFont();
			this.rightFormat = this.book.addFormat(this.textFormat);
			this.rightFormat.alignH = AlignH.ALIGNH_RIGHT;
			this.leftFormat = this.book.addFormat(this.textFormat);
			this.leftFormat.alignH = AlignH.ALIGNH_LEFT;
			this.intFormat = this.book.addFormat(this.textFormat);
			this.intFormat.setNumFormat(NumFormat.NUMFORMAT_ACCOUNT);
			this.douFormat = this.book.addFormat(this.textFormat);
			this.douFormat.setNumFormat(NumFormat.NUMFORMAT_ACCOUNT_D2);
			this.percentFormat = this.book.addFormat(this.textFormat);
			this.percentFormat.setNumFormat(NumFormat.NUMFORMAT_PERCENT_D2);
		}

		private Font CreateFileTitleFont()
		{
			Font font = this.book.addFont();
			font.size = 13;
			font.name = "黑体";
			font.bold = true;
			return font;
		}

		private Font CreateSubTitleFont()
		{
			Font font = this.book.addFont();
			font.size = 12;
			font.name = "黑体";
			return font;
		}

		private Font CreateTextFont()
		{
			Font font = this.book.addFont();
			font.name = "宋体";
			font.size = 10;
			return font;
		}

		private void SaveFile()
		{
			int num = 1;
			while (File.Exists(this.path))
			{
				this.path = string.Concat(new object[]
				{
					Product.UserDataLocation,
					"\\盈建科BIM采暖系统水力计算书",
					num,
					".xls"
				});
				num++;
			}
			this.book.save(this.path);
		}

		private void SetBkWorInfo(int step, string messge = "")
		{
			Log.Info(new string[]
			{
				messge
			});
			if (this.backWorker == null)
			{
				return;
			}
			this.rate += step;
			if (this.rate > 100)
			{
				this.rate = 100;
			}
			if (string.IsNullOrEmpty(messge))
			{
				this.backWorker.ReportProgress(this.rate);
				return;
			}
			this.backWorker.ReportProgress(this.rate, messge);
		}

		private BuildingSystem buildingSystem;

		private HYHeatingSystemOption heatingOption;

		private string path = Product.UserDataLocation + "\\盈建科BIM采暖系统水力计算书.xls";

		private readonly string title1 = "采暖系统分户计量水力计算表";

		private readonly string title2 = "高级设置计算数据";

		private Book book;

		private BackgroundWorker backWorker;

		private int rate;

		private Format titleFormat;

		private Format subTitleFormat;

		private Format textFormat;

		private Format intFormat;

		private Format douFormat;

		private Format percentFormat;

		private Format rightFormat;

		private Format leftFormat;
	}
}
